var editGrowth = {

    checkFrom: function () {

        var form = $("#growthForm");
        if (form == null) return;

        var json = JWB.utils.fromSerialize(form);
        var flag = true;
        if (json["growth.name"] == '') {
            $("#name").parent().addClass("has-error");
            flag = false;
        } else {
            $("#name").parent().removeClass("has-error");
        }
        if (json["growth.rank"] == '') {
            $("#rank").parent().addClass("has-error");
            flag = false;
        } else {
            $("#rank").parent().removeClass("has-error");
        }
        return flag;
    },
    submitForm: function (growthId) {
        if (editGrowth.checkFrom() == true) {
            var url = base.basePath + "/growth/save";
            var data = JWB.utils.fromSerialize($("#growthForm"));
            $.ajax(
                {
                    url: url,
                    data: data,
                    type: "POST",
                    success: function (res) {
                        alert(res.msg);
                        if (res.code == 0) {
                            editGrowth.closeWindow();
                            if(growthId){
                                index_js.loadRightPage("page/growth.cgi?growthId=" + growthId);
                            }else {
                                location.reload();
                            }
                        }
                    },
                    error: function (jXHR, textStatus, errorThrown) {
                        JWB.http.errorHandle(jXHR, textStatus, errorThrown);
                    }
                }
            )
        }
    },
    closeWindow: function () {
        $("#editGrowthPage").remove();
        // index_js.hiddenFloatage();
    }
}